﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tb_User_ServiceDAL : SqlDataProvider
	{

		#region[tb_User_Service_GetbyAll]
		public DataTable tb_User_Service_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_Service_GetbyId]
		public DataTable tb_User_Service_GetById(tb_User_ServiceInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@ServiceId", Data.ServiceId));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_Service_GetbyTop]
		public DataTable tb_User_Service_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_Service_GetbyServiceId]
		public DataTable tb_User_Service_GetByServiceId(string ServiceId)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_GetByServiceId", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@ServiceId", ServiceId));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_Service_GetbyUsername]
		public DataTable tb_User_Service_GetByUsername(string Username)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_GetByUsername", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Username));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_User_Service_Insert]
		public void tb_User_Service_Insert(tb_User_ServiceInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@ServiceId", Data.ServiceId));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_User_Service_Update]
		public void tb_User_Service_Update(tb_User_ServiceInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@ServiceId", Data.ServiceId));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_User_Service_Delete]
		public void tb_User_Service_Delete(tb_User_ServiceInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_User_Service_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@ServiceId", Data.ServiceId));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}